package com.base.pig.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.base.pig.entity.MonthReport;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yjh
 * @since 2022-05-24
 */
@Mapper
public interface MonthReportMapper extends BaseMapper<MonthReport> {

    @Select(" select  left(t.date,10) date  ,t.pointName,t.deviceId,t.sensorCode,sum(t.avg) avg ,sum(t.max) max,sum(t.min) min " +
            " from   month_report t   where  left(t.date,10)   =#{date}  " +
            " group by  t.pointName,t.deviceId,t.sensorCode,left(t.date,10)     ")
    List<MonthReport> getGatherMonthReport(@Param("date") String date);


    @Select(" select  left(t.date,7)  date ,t.deviceId,t.sensorCode,avg(t.avg) avg  ,max(t.max) max,min(t.min)  min " +
            "            from   month_report t  where left(t.date,7) >= #{startDate}   and   left(t.date,7) <= #{endDate} " +
            "            AND t.deviceId =#{deviceId} AND t.sensorCode = #{sensorCode}  " +
            "            group by  t.deviceId,t.sensorCode,left(t.date,7)     ")
    List<MonthReport> getGatherYearReport(@Param("startDate") String startDate, @Param("endDate") String endDate,
                                          @Param("deviceId") String deviceId, @Param("sensorCode") String sensorCode);




}
